#include "console.h"
#include "MenuManager.h"
#include "Menu.h"
#include "GameController.h"
#include "Global.h"

#include "GameManager.h"

#include <string>
#include <vector>
#include <thread>

using namespace std;

int main() {
	// Init Console
	Console c("Zalcetto", Consts::SCREEN_WIDTH, Consts::SCREEN_HEIGHT);

	// Init Game
	GameController gc;
	MenuManager* mm = gc.GetMM();

	// Loop Variables
	const chrono::milliseconds sleep_time(1);
	vector<Input> inputs;
	Menu* current_menu = mm->GetCurrentMenu();

	// Game Loop
	while (current_menu) {
		c.ReadInputs(inputs);

		Menu* next_menu = current_menu->Input(inputs);

		if (next_menu != current_menu) {
			mm->SetMenu(next_menu);
		}

		current_menu = mm->GetCurrentMenu();
		if (current_menu) {
			current_menu->Draw(c);

			while (c.TimeElapsedSinceLastFlush() < 0.05f) {
				this_thread::sleep_for(sleep_time);
			}
			c.Flush();
		}
	}
}

